package com.flong.spring.conditional;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @Author:liangjl
 * @Date: 2020/6/10-20:51
 * @Eamil:jilongliang@sina.com
 * @Description:
 * 自定义导入选择器
 */
public class MyImportSelector implements ImportSelector {

    /**
     * 返回值，就是导入到容器的组件全类名
     * @see AnnotationMetadata 当前标注@Import注解的类的所有注解信息
     * @param importingClassMetadata
     * @return
     */
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {

        //这里不能返回一个null，底层会报NPE(NullPointerException)
        return new String[]{"com.flong.spring.bean.Blue"};
    }
}
